#include "Timestamp.h"
#include <iostream>

Timestamp::Timestamp()
{
    m_sec_since_epoch=time(0);
}

Timestamp::Timestamp(time_t sec_since_epoch)
{
    m_sec_since_epoch = sec_since_epoch;
}

time_t Timestamp::to_int()
{
    return m_sec_since_epoch;
}

std::string Timestamp::to_string()
{
    char buf[32]={0};
    tm *tm_time=localtime(&m_sec_since_epoch);
    snprintf(buf,20,"%4d-%02d-%02d %02d:%02d:%02d",
            tm_time->tm_year+1900,
            tm_time->tm_mon+1,
            tm_time->tm_mday,
            tm_time->tm_hour,
            tm_time->tm_min,
            tm_time->tm_sec);
    return buf;
}

Timestamp Timestamp::now()
{
    return Timestamp();
}
